from django.db import models
# import json

# Create your models here.
class PowerLogs(models.Model):
    """
    算力日志
    type:
    (1) // 充值
    (2) // 消费
    (3) // 任务（SD,MJ）执行失败，退款
    (4) // 邀请奖励
    (5) // 众筹
    (6) // 系统赠送
    (7) // 兑换码

    mark:
    0 : sub
    1 : add
    """
    id = models.BigAutoField(primary_key=True)
    user_id = models.TextField(verbose_name="用户ID", blank=False, null=False)
    username = models.CharField(verbose_name="用户名", max_length=32, blank=False, null=False)
    type = models.IntegerField(verbose_name="类型", blank=False, null=False)
    amount = models.IntegerField(verbose_name="数额", blank=False, null=False)
    balance = models.IntegerField(verbose_name="余额", blank=False, null=False)
    model = models.CharField(verbose_name="模型值", max_length=256, blank=False, null=False)
    remark = models.CharField(verbose_name="备注", max_length=256, null=True, blank=True, default=None)
    mark = models.BooleanField(verbose_name="资金类型", blank=False, null=False)

    created_at = models.DateTimeField(auto_now_add=True)


    
    # config_json = models.TextField(verbose_name="配置", blank=False, null=False)

    # def __str__(self):
    #     return self.marker

    # def set_json_data(self, data):
    #     self.config_json = json.dumps(data)

    # def get_json_data(self):
    #     return json.loads(self.config_json)

